import { ApiCall } from "tsrpc";
import { ReqUse_resState, ResUse_resState } from "../../../../shared/master/bag/function/PtlUse_resState";
import { player } from "../../../../model/fight/body/player";
import { group, EffectType } from "../../../../shared/interface";
import { template } from "../../../../shared/master/MsgAction";
let timeMap:Map<string,number> = new Map();
export default async function (call: ApiCall<ReqUse_resState, ResUse_resState>) {
    call.succ({})
    let user = call.req._player as player;
    if(user.get_battle()){
        user.sendMsg(template.default,'此道具不能在战斗中使用哦')
        return;
    }
    let lastTime = timeMap.get(user.uuid) || 0;
    if (Date.now() - lastTime < 5000) {
        user.sendMsg(template.default,'每5秒只能使用一次治疗哦')
        return;
    }
    let res = user.check_wallet(0, 0, [{ id: 'prop-19', v: 1 }], false, '重置血统', true);
    if (!res.state) {
        return;
    }
    timeMap.set(user.uuid,Date.now());
    user.add_hp({
        use_uuid: "0",
        use_name: "主神空间",
        sk_name: "圣愈术",
        group: group.客场,
        type: EffectType.none,
        val: Math.ceil(user._attributes.Hp_Max * 0.2)
    },true)
    user.add_mp({
        use_uuid: "0",
        use_name: "主神空间",
        sk_name: "清晰头脑",
        group: group.客场,
        type: EffectType.none,
        val: Math.ceil(user._attributes.Mp_Max * 0.2)
    },true)
}